#ifndef APPLOADER_H
#define APPLOADER_H

#include <string>
#include <vector>
#include <App.h>
#include <AppView.hpp>

/**
 * Class that enable dynamic load of application
 */
class AppLoader {
public:
  /**
   * Creates an instance of the loader system
   * @param folder the base folder where plugins are located
   */
  AppLoader(std::string folder);

  /**
   * Destroy the loader and the loaded apps
   */
  ~AppLoader();

  /**
   * Load an application with the given name
   * @param name the name of the application
   * @returns a full specified application container
   */
  App* loadApp(std::string name);

  /**
   * Destroy an application
   */
  void unloadApp(App*);

protected:
  /**
   * Search plugins stored inside the folder
   */
  void searchAvailablePlugins();

private:
  std::string _folder;
  std::string _extension;
  std::vector<App*> _loaded;
  std::vector<std::string> _available;
};

#endif
